/**
 * Copyright (C), 2015-2020, XXX有限公司
 * FileName: PoiListAdapter
 * Author: Clark
 * Date: 2020/10/10 15:57
 * Description:
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
package sz.szsmk.citizencard.ui.adapter;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.seapeak.recyclebundle.BaseHolder;
import com.seapeak.recyclebundle.BaseRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.PopTripPlanDesItemBinding;
import sz.szsmk.citizencard.databinding.SearchViewItemBinding;
import sz.szsmk.citizencard.model.network.bean.response.PoiBean;
import sz.szsmk.citizencard.model.network.bean.response.SearchViewResponse;
import sz.szsmk.citizencard.util.ACache;
import sz.szsmk.citizencard.util.Constant;
import sz.szsmk.citizencard.util.GlideRoundTransform;
import sz.szsmk.citizencard.util.JumpUtils;

/**
 * @ClassName: PoiListAdapter
 * @Description:
 * @Author: Clark
 * @Date: 2020/10/10 15:57
 */
public class PoiListAdapter extends BaseRecyclerAdapter<PoiListAdapter.PoiListHolder> {

    private Context mContext;
    private List<PoiBean> viewData=new ArrayList<>();

    public PoiListAdapter(Context context) {
        mContext = context;

    }

    @Override
    public PoiListAdapter.PoiListHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return PoiListAdapter.PoiListHolder.creat(parent);
    }

    @Override
    public void onBindViewHolder(PoiListAdapter.PoiListHolder holder, int position) {
        loadItemData(position, holder.binding);
    }

    private void loadItemData(int position, PopTripPlanDesItemBinding binding) {
        if (viewData != null && viewData.size() > 0) {
            PoiBean poiBean = viewData.get(position);
            binding.desName.setText(poiBean.getTitle());
            binding.desAddress.setText(poiBean.getSnippet());


//        binding.alltypeShopname.setText(hotelData.get(position).getName());
//        binding.alltypeAdress.setText(hotelData.get(position).getAddress());
        }
    }

    @Override
    public int getItemCount() {
        return null == viewData ? 0 : viewData.size();
    }

    public void setViewData(List<PoiBean> viewData) {
        if (viewData != null) {
            this.viewData.clear();
            this.viewData.addAll(viewData);
        }
    }



    public static class PoiListHolder extends BaseHolder {

        private PopTripPlanDesItemBinding binding;

        public static PoiListHolder creat(ViewGroup parent) {
            PopTripPlanDesItemBinding binding = PopTripPlanDesItemBinding
                    .inflate(LayoutInflater.from(parent.getContext()), parent, false);
            return new PoiListHolder(binding);
        }
        public PoiListHolder(PopTripPlanDesItemBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
    }
}